/*
 *    Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: lengleng (wangiegie@gmail.com)
 */
package com.excesys.exsecs.om.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.excesys.exsecs.om.dto.SynchronizationDto;
import com.excesys.exsecs.om.entity.OmEvenAndRegion;
import com.excesys.exsecs.om.entity.OmInspectionItems;
import com.excesys.exsecs.om.mapper.OmEvenAndRegionMapper;
import com.excesys.exsecs.om.mapper.OmInspectionItemsMapper;
import com.excesys.exsecs.om.service.OmEventAndRegionService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @date 2023-05-19
 */
@RequiredArgsConstructor
@Service
public class OmEventAndRegionServiceImpl extends ServiceImpl<OmEvenAndRegionMapper, OmEvenAndRegion>
		implements OmEventAndRegionService {

	private final OmEvenAndRegionMapper omEvenAndRegionMapper;

	private final OmInspectionItemsMapper omInspectionItemsMapper;

	@Override
	public List<OmInspectionItems> getIdList(String id) {
		List<OmInspectionItems> list = omInspectionItemsMapper
				.getItemsLists(omEvenAndRegionMapper.getIdList(id).get(0).getRegionCode());
		return list;
	}

	@Override
	public void deleteByCode(String regionCode, Integer id) {
		omEvenAndRegionMapper.deleteByCode(regionCode, id);
	}

	@Override
	public Boolean getRegion(SynchronizationDto synchronizationDto) {
		List<OmEvenAndRegion> list = omEvenAndRegionMapper.getRegion(synchronizationDto.getPid(),
				synchronizationDto.getId());
		if (list.size() > 0)
			return true;
		else
			return false;
	}

	@Override
	public void updateById(String regionCode) {
		omEvenAndRegionMapper.updateById(regionCode);
	}

	@Override
	public List<OmEvenAndRegion> getRegionList(String id) {
		return omEvenAndRegionMapper.getRegionList(id);
	}

	@Override
	public void deleteAll(String id) {
		omEvenAndRegionMapper.deleteAll(id);
	}

}
